package com.mdd.admin.controller;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.index.IIndexVisitService;
import com.mdd.admin.validate.index.IndexVisitParam;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.utils.IpUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 首页浏览记录管理
 * @author panweiliang
 */
@RestController
@RequestMapping("api/index/visit")
public class IndexVisitController {

    @Resource
    IIndexVisitService iIndexVisitService;


    /**
     * 首页浏览记录新增
     *
     * @author panweiliang
     * @param indexVisitParam 参数
     * @return Object
     */
    @Log(title = "首页浏览记录新增")
    @PostMapping("/add")
    public Object add(@Validated(value = IndexVisitParam.create.class) @RequestBody IndexVisitParam indexVisitParam) {
        iIndexVisitService.addOrUpdate(indexVisitParam.getTerminal(), IpUtil.getHostIp());
        return AjaxResult.success();
    }



}
